<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="/Esquina_da_TI/default.css" rel="stylesheet" type="text/css" media="screen" />
        <title>Controle dos Foruns</title>
    </head>
    <body>
        <center>
            <h1>Controle dos Foruns</h1>
            <form id="relatorioCliente" name="relatorioCliente" action="" method="post">
                <table border="1">

                    <?php
                    require_once ($_SERVER["DOCUMENT_ROOT"] . '/Esquina_da_TI/Dao/Conexao.php');
                    require_once ($_SERVER["DOCUMENT_ROOT"] . '/Esquina_da_TI/ClassesBasicas/Privilegio.php');
                    require_once ($_SERVER["DOCUMENT_ROOT"] . '/Esquina_da_TI/Gui/Fachada.php');
                    $conexao = new Conexao();
                    $conexao->abrirConexao();

                    $query = "SELECT forum.titulo AS 'forum', assunto.nome AS 'assunto', topico.titulo AS 'topico'
                                FROM topico
                                INNER JOIN assunto ON topico.assunto = assunto.codAssunto
                                INNER JOIN forum ON assunto.codForum = forum.codForum";

                    $result = $conexao->executarQuery($query);
                    $forunAnterior = "";
                    while($row = mysql_fetch_array($result)){
                        

                        if($forunAnterior != $row['forum']){
                            $forunAnterior = $row['forum'];
                            echo "<tr>
                                <td class='head'><a href=\"exibirAssuntos.php?forum=".$row['forum']."\">".
                                    $row['forum'].
                                "</td>
                            </tr>";
                        }
                        echo "<tr>
                                <td class='responder'>
                                    <a href=\"exibirTopico.php?forum=".$row['forum']."&assunto=".$row['assunto']."&topico=".$row['topico']."\">".
                                    $row['topico']. "</a>&nbsp;&nbsp;<a href=\"ExcluirTopico.php?topico=".$row['topico']."\"><img src=\"../images/btn_excluir.jpg\" /></a>
                                </td>
                            </tr>";
                    }                 
                    ?>
                </table>
            </form>
        </center>
    </body>
</html>
